﻿<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="Template"
    elementFormDefault="qualified"
    targetNamespace="http://svegi.hr/BizElements/TemplateEngine/Template.xsd"    
    xmlns="http://svegi.hr/BizElements/TemplateEngine/Template.xsd"
    xmlns:mstns="http://svegi.hr/BizElements/TemplateEngine/Template.xsd"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
>
  <xs:element name="Template" type="TemplateDef" />
  <xs:complexType name="TemplateDef">
    <xs:sequence>
      <xs:element name="Header" type="HeaderDef" minOccurs="1" maxOccurs="1" />
      <xs:element name="Variables" type="VariableCollectionDef" minOccurs="0" maxOccurs="1" />
      <xs:element name="Settings" type="SettingCollectionDef" minOccurs="0" maxOccurs="1" />
      <xs:element name="ComponentVariables" type="ComponentVariableCollectionDef" minOccurs="0" maxOccurs="1" />
      <xs:element name="ReferencedAssemblies" type="ReferencedAssembliesDef" minOccurs="0" maxOccurs="1" />
      <xs:element name="Namespaces" type="NamespacesDef" minOccurs="0" maxOccurs="1" />
      <xs:element name="InputComponentBuilder" type="InputComponentBuilderDef" minOccurs="0" maxOccurs="1" />      
      <xs:element name="InputComponentCriteria" type="InputComponentCriteriaDef" minOccurs="0" maxOccurs="1" />
      <xs:element name="CodeDomProvider" type="CodeDomProviderDef" minOccurs="0" maxOccurs="1" />
      <xs:element name="TemplateSegments" type="TemplateSegmentCollectionDef" minOccurs="1" maxOccurs="1" />
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="HeaderDef">
    <xs:sequence>
      <xs:element name="Title" type="xs:string" nillable="false" minOccurs="1" maxOccurs="1" />
      <xs:element name="Description" type="xs:string" minOccurs="0" maxOccurs="1" />
      <xs:element name="Family" type="FamilyDef" minOccurs="1" maxOccurs="1" />
    </xs:sequence>
  </xs:complexType>
  <xs:simpleType name="FamilyDef">
    <xs:restriction base="xs:string">
      <xs:enumeration value="OrmConfig"></xs:enumeration>
      <xs:enumeration value="SP"></xs:enumeration>
      <xs:enumeration value="ORM"></xs:enumeration>
      <xs:enumeration value="EntityUI"></xs:enumeration>
      <xs:enumeration value="Other"></xs:enumeration>
    </xs:restriction>
  </xs:simpleType>
  <xs:complexType name="VariableCollectionDef">
    <xs:sequence>
      <xs:element name="Variable" type="VariableDef" minOccurs="0" maxOccurs="unbounded"/>
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="VariableDef">
    <xs:sequence>
      <xs:element name="Name" type="xs:string" nillable="false" minOccurs="1" maxOccurs="1" />
      <xs:element name="Description" type="xs:string" minOccurs="1" maxOccurs="1" />
      <xs:element name="DefaultValue" type="xs:string" minOccurs="1" maxOccurs="1" />
      <xs:element name="AllowedValues" type="AllowedValuesDef" minOccurs="0" maxOccurs="1"/>
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="ComponentVariableCollectionDef">
    <xs:sequence>
      <xs:element name="ComponentVariable" type="ComponentVariableDef" minOccurs="0" maxOccurs="unbounded"/>
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="ComponentVariableDef">
    <xs:sequence>
      <xs:element name="Name" type="xs:string" nillable="false" minOccurs="1" maxOccurs="1" />
      <xs:element name="Description" type="xs:string" minOccurs="1" maxOccurs="1" />
      <xs:element name="DefaultValue" type="xs:string" minOccurs="1" maxOccurs="1" />
      <xs:element name="AllowedValues" type="AllowedValuesDef" minOccurs="0" maxOccurs="1"/>
      <xs:element name="UsedFor" type="InputComponentCriteriaDef" minOccurs="0" maxOccurs="1" />
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="AllowedValuesDef">
    <xs:sequence>
      <xs:element name="ListItem" type="ListItemDef" minOccurs="1" maxOccurs="unbounded" />
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="ListItemDef">
    <xs:sequence>
      <xs:element name="Name" type="xs:string" nillable="false" minOccurs="1" maxOccurs="1" />
      <xs:element name="Value" type="xs:string" nillable="false" minOccurs="1" maxOccurs="1" />
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="SettingCollectionDef">
    <xs:sequence>
      <xs:element name="Setting" type="SettingDef" minOccurs="0" maxOccurs="unbounded" />
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="SettingDef">
    <xs:sequence>
      <xs:element name="Name" type="xs:string" nillable="false" minOccurs="1" maxOccurs="1" />
      <xs:element name="Description" type="xs:string" minOccurs="0" maxOccurs="1" />
      <xs:element name="Value" type="xs:string" minOccurs="1" maxOccurs="1" />
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="ReferencedAssembliesDef">
    <xs:sequence>
      <xs:element name="Assembly" type="xs:string" nillable="false" minOccurs="0" maxOccurs="unbounded" />
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="NamespacesDef">
    <xs:sequence>
      <xs:element name="Using" type="xs:string" nillable="false" minOccurs="0" maxOccurs="unbounded" />
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="InputComponentBuilderDef">
    <xs:sequence>
      <xs:element name="Assembly" type="xs:string" nillable="false" minOccurs="1" maxOccurs="1" />
      <xs:element name="Class" type="xs:string" nillable="false" minOccurs="1" maxOccurs="1" />
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="CodeDomProviderDef">
    <xs:sequence>
      <xs:element name="AssemblyString" type="xs:string" nillable="false" minOccurs="1" maxOccurs="1" />
      <xs:element name="ClassName" type="xs:string" nillable="false" minOccurs="1" maxOccurs="1" />
      <xs:element name="CompilerVersion" type="xs:string" nillable="false" minOccurs="1" maxOccurs="1" />
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="InputComponentCriteriaDef">
    <xs:sequence>
      <xs:element name="BooleanExpression" type="xs:string" nillable="false" minOccurs="1" maxOccurs="1" />
      <xs:element name="Name" type="xs:string" nillable="false" minOccurs="1" maxOccurs="1" />
      <xs:element name="Description" type="xs:string" nillable="false" minOccurs="1" maxOccurs="1" />
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="TemplateSegmentCollectionDef">
    <xs:sequence>
      <xs:element name="TemplateSegment" type="TemplateSegmentDef" nillable="false" minOccurs="1" maxOccurs="unbounded" />
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="TemplateSegmentDef" mixed="true">
    <xs:attribute name="Id" use="required" type="xs:string" />
    <xs:attribute name="Debug" use="optional" type="xs:boolean" />
    <xs:attribute name="DebugIfInputName" use="optional" type="xs:string" />
  </xs:complexType>
</xs:schema>
